package cn.four.hqServer.modules.account.controller;


import cn.four.hqServer.common.result.Result;
import cn.four.hqServer.modules.account.service.ZnbIHqUserBalanceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author znb
 * @since 2023-02-22
 */
@Api(tags = "存款利息结算")
@RestController
@RequestMapping("/account")
public class ZnbAccountController {

    @Autowired
    private ZnbIHqUserBalanceService service;

    /**
     * 更新利率
     * @param lilu
     * @return
     */
    @ApiOperation(value = "更新利率")
    @GetMapping("/update/{lilu}")
    public Result updateL(@PathVariable String lilu) {
        if (service.updateL(lilu)) {
            return Result.success();
        } else {
            return Result.error("更新失败");
        }
    }


    @GetMapping("/every")
    @ApiOperation(value = "计入用户余额日记表")
    public Result<String> everyAdd(){
        if(service.everyAdd()){
            return Result.success("成功");
        }else{
            return Result.error("计入用户余额日记表出错");
        }
    }

    @GetMapping("/interest")
    @ApiOperation(value = "结息")
    public Result<String> interest(){
        if(service.interest()){
            return Result.success("成功");
        }else {
            return Result.error("结息失败");
        }
    }
}
